<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item" >
        <label class="layui-form-label">快递信息</label>
        <div class="layui-input-block">
            <select type="text" id="express" name='express' class="layui-input" value=""lay-search="" lay-filter="express"></select>
        </div>
      </div>
    <div class="layui-form-item" >
        <label class="layui-form-label required">快递单号</label>
        <div class="layui-input-block">
            <input type="text" name="expresssn" id="expresssn" lay-verify="required" lay-reqtext="快递单号不能为空" placeholder="请输入快递单号" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-radius layui-btn-primary" lay-submit lay-filter="saveBtn" id="saveBtn">确认保存</button>
            <button class="layui-btn layui-btn-radius layui-btn-primary"  id="backBtn">返回</button>
        </div>
    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js" charset="utf-8"></script>
<script src="../../js/custorm/init.js"></script>
<script>
    layui.use(['form','treeSelect','iconPickerFa'], function () {
        var form = layui.form,
         iconPickerFa = layui.iconPickerFa,
            layer = layui.layer,treeSelect=layui.treeSelect,
            $ = layui.$;
        
        //HavePermission('consignment')==true?$("#saveBtn").show():$("#saveBtn").hide();
        var order={id:0,expresssn:'',expressname:''};
        $(document).ready(function(){
            var content = window.location.href;
            var id = content.split('=')[content.split('=').length - 1];
            order.id=parseInt(id);
            AxajGet('../../api/shop/GetAllShipping','../../login.html',initParentSelect)
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            order.expressname=data.field.express;
            order.expresssn=data.field.expresssn;
            AxajPost('../../api/shop/Consignment',order,'发货成功','../../login.html');
        });
        $("#backBtn").click(function () {
            window.location.href="../order.html";
        });

        function initParentSelect(data){
            $('#express').html('');
            $("#express").append("<option></option>");
            for (var i = 0; i < data.length; i++) {
                    $("#express").append("<option value='"+data[i].name+"'>" + data[i].name+ "</option>");
            }
            form.render();
        }
    });
</script>
</body>
</html>